ng911ok.lib.legacy module#
Script counterpart to legacy.yml.
- class LegacyFieldInfo(next_gen: str, legacy: str, concatenation: bool, equal: bool, value_map=None)#
Bases:
objectContains information and performs conversions relating to corresponding pairs of next-gen/legacy fields. This class should not typically be instantiated directly! Use
load()orfor_field()instead.- classmethod for_field(field: NG911Field | None = None, *, role: str | None = None, name: str | None = None) Self#
Given an argument denoting either a legacy field or a next-gen field with a corresponding legacy field, returns an instance of this class with data relevant to that field.
- classmethod load() FrozenList[Self]#
Loads the data from
legacy.ymland returns a list of instances of this class corresponding to each entry under thefieldskey in that file.
- compare_columns(df: DataFrame) Series#
Given a feature class data frame, evaluates whether the values in the column with the same name as
self.legacy.namecorrespond as expected to the values in the column namedself.next_gen.name. Returns a booleanSeries(with the same index as df) indicating whether the value in the legacy column was indeed the expected value.- Parameters:
df (pandas.DataFrame) – Feature class data frame
- Returns:
Boolean validity series
- Return type:
pandas.Series
- get_legacy_value(next_gen_value: str) str | None#
Given a next-gen value present in an instance’s
value_map, returns the corresponding legacy value. If there is no match,Noneis returned.
- get_next_gen_value(legacy_value: str) str | None#
Given a legacy value present in an instance’s
value_map, returns a corresponding next-gen value. In cases where a legacy value matches multiple next-gen values, only one next-gen value will be returned. If there is no match, or ifvalue_mapis empty, this method returnsNone.
- get_next_gen_values(legacy_value: str) Series#
Given a legacy value present in an instance’s
value_map, returns apandas.Serieswith any corresponding next-gen values. Most, but not all, legacy values correspond to only one next-gen value. If there is no match, an emptypandas.Serieswill be returned.
- _value_map: FrozenDict[str, str] | None#
Mapping from the next-gen to the corresponding legacy values.
- concatenation: bool#
Whether the fields in the legacy/next-gen field pair are intended to be a concatenation of other fields.
- equal: bool#
Whether the values of the legacy field should always equal those of the next-gen field.
- legacy: NG911Field#
Legacy field of a legacy/next-gen field pair.
- next_gen: NG911Field#
NG911 field of a legacy/next-gen field pair.
- property value_map: Series#
Returns a
pandas.Seriesof the instance’s value map.
- convert_legacy_fields(gdb: str, feature_classes: Sequence[NG911FeatureClass], legacy_fields: Sequence[NG911Field], convert_to: Literal['LEGACY', 'NEXTGEN'], update_nulls_only: bool = True) int#
Performs field conversions related to legacy abbreviations.
- Parameters:
gdb – Geodatabase path
feature_classes – Feature classes containing the supplied legacy_fields to include in the conversion
legacy_fields – The legacy fields involved in the conversion (the corresponding next-gen fields will be determined automatically)
convert_to – Direction to convert to; use
"LEGACY"to convert from next-gen to legacy, or use"NEXTGEN"to convert from legacy to next-genupdate_nulls_only – Whether to only overwrite values that are null, default True
- Returns:
Number of feature attributes updated